package com.tonyodev.fetch2fileserver.database;

import ohos.data.orm.OrmObject;
import ohos.data.orm.annotation.Column;
import ohos.data.orm.annotation.PrimaryKey;

import java.util.Objects;

public class FileResourceInfo extends OrmObject {

    public static final String TABLE_NAME = "fileResourceInfo";
    public static final String COLUMN_ID = "_id";
    public static final String COLUMN_LENGTH = "_length";
    public static final String COLUMN_FILE = "_file";
    public static final String COLUMN_NAME = "_name";
    public static final String COLUMN_EXTRAS = "_customData";
    public static final String COLUMN_MD5 = "_md5";
    public static final int MAX_PAGE_SIZE = 100;
    @PrimaryKey
    private long id;
    @Column(name = "_length")
    private long length;
    @Column(name = "_file")
    private String file = "";
    @Column(name = "_name")
    private String name = "";
    @Column(name = "_customData")
    private String extras = "";
    @Column(name = "_md5")
    private String md5 = "";

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getLength() {
        return length;
    }

    public void setLength(long length) {
        this.length = length;
    }

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getExtras() {
        return extras;
    }

    public void setExtras(String extras) {
        this.extras = extras;
    }

    public String getMd5() {
        return md5;
    }

    public void setMd5(String md5) {
        this.md5 = md5;
    }


    public FileResourceInfo() {
    };
    public FileResourceInfo(long id, long length, String file, String name, String extras, String md5) {
        this.id = id;
        this.length = length;
        this.file = file;
        this.name = name;
        this.extras = extras;
        this.md5 = md5;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FileResourceInfo that = (FileResourceInfo) o;
        return id == that.id &&
            length == that.length &&
            Objects.equals(file, that.file) &&
            Objects.equals(name, that.name) &&
            Objects.equals(extras, that.extras) &&
            Objects.equals(md5, that.md5);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, length, file, name, extras, md5);
    }

    @Override
    public String toString() {
        return "FileResourceInfo{" +
            "id=" + id +
            ", length=" + length +
            ", file='" + file + '\'' +
            ", name='" + name + '\'' +
            ", extras='" + extras + '\'' +
            ", md5='" + md5 + '\'' +
            '}';
    }
}
